package com.neusoft.zqygbc.neusoft_wenda.activity;

import android.content.Intent;
import android.content.SharedPreferences;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.view.View;
import android.widget.ImageView;
import android.widget.Toast;

import com.jcodecraeer.xrecyclerview.XRecyclerView;
import com.neusoft.zqygbc.neusoft_wenda.R;
import com.neusoft.zqygbc.neusoft_wenda.adapter.FollowAdapter;
import com.neusoft.zqygbc.neusoft_wenda.base.RetrofitCallback;
import com.neusoft.zqygbc.neusoft_wenda.javeBean.FollowEntity;
import com.neusoft.zqygbc.neusoft_wenda.javeBean.FollowList;
import com.neusoft.zqygbc.neusoft_wenda.model.FollowModel;

import java.util.List;

import retrofit2.Call;

public class MyFollowActivity extends BaseAvtivity {

    private XRecyclerView myfollow_xrv;
    private ImageView myfollow_return;
    private FollowModel followModel;
    private Call call;
    private RetrofitCallback<FollowList> followCallback;
    private FollowAdapter adapter;
    private Intent intent;

    @Override
    void initViews() {
        setLayout(R.layout.activity_my_follow);
        myfollow_xrv = (XRecyclerView) findViewById(R.id.myfollow_xrv);
        myfollow_xrv.setLayoutManager(new LinearLayoutManager(MyFollowActivity.this));
        myfollow_return = (ImageView) findViewById(R.id.myfollow_return);
        intent = getIntent();
    }

    @Override
    void initEvents() {
        myfollow_return.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                finish();
            }
        });

    }

    @Override
    void initData() {
        //Toast.makeText(MyFollowActivity.this, sp.getString("user_id", ""), Toast.LENGTH_SHORT).show();
        followModel = new FollowModel();
        call = followModel.followlist(intent.getStringExtra("user_id"));
        followCallback = new RetrofitCallback<FollowList>() {
            @Override
            public void onResponse(FollowList followList) {
                List<FollowEntity> follows = followList.getFollow();
                adapter = new FollowAdapter(MyFollowActivity.this, follows, R.layout.cardview_myfollow);
                myfollow_xrv.setAdapter(adapter);
            }
        };
        followModel.bindCallback(call, followCallback);
    }
}
